* formal_graph.do	JEP	01/27/15
* Build regression table
* Formal sector, wages

*************************** Change log ********************************** 

/*
	
*/	

clear 
version 13.1

* Project info
cap project, doinfo
if _rc==198 {
	if c(username)=="J16339" loc master "B:\Col_Minimum_Wage" 
	else if c(os)=="Windows" loc master "C:/Users/jorpp/Dropbox (Brown)/Col_Minimum_Wage"
	else loc master "/home/jperez/AA_Minimum_Wage"
}
else {
	local master "`r(pdir)'"
	local doname "`r(dofile)'" 
	* Project calls
	project, relies_on("`master'/Code/Est/rifregtable2.do")
	project, relies_on("`master'/Code/Est/graph_multirif.do")
	/*
	foreach x in 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 {
		project, uses("`master'/Ster/rif4_new_med_indcc/reg_emp_bp_tq(1999q1)_bite_salario_mensual_real_50_edom_indcc_p`x'.ster")
		project, uses("`master'/Ster/rif4_new_ebite_indcc/reg_emp_bp_tq(1999q1)_ebite_salario_mensual_real_50_edom_indcc_p`x'.ster")
		project, uses("`master'/Ster/rif4_new_indcc/reg_emp_bp_tq(1999q1)_bite_salario_mensual_real_50_edom_indcc_p`x'.ster")
	}
	*/
}
foreach x in 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 {

	* Copy the needed files to a single folder
	copy "`master'/Ster/rif4_new_indcc/reg_emp_bp_tq(1999q1)_bite_salario_mensual_real_50_edom_indcc_p`x'.ster" "`master'/Ster/eoy/reg_emp_bp_tq(1999q1)_bite_salario_mensual_real_50_edom_indcc_p`x'.ster" , replace

	copy "`master'/Ster/rif4_new_indcc/reg_emp_bp_tq(1998q1)_ejercicio3_p`x'.ster" "`master'/Ster/eoy/reg_emp_bp_tq(1998q1)_bite_salario_mensual_real_50_edom_indcc_p`x'.ster" , replace

	copy "`master'/Ster/rif4_new_indcc/reg_emp_bp_tq(1997q1)_ejercicio3_p`x'.ster" "`master'/Ster/eoy/reg_emp_bp_tq(1997q1)_bite_salario_mensual_real_50_edom_indcc_p`x'.ster" , replace 
}


cap program drop mex
program define mex
	cap mkdir "`2'/Doc"
	cap mkdir "`2'/Doc/tosubmit2"
	cap mkdir "`2'/Doc/tosubmit2/fig"
	graph export "`2'/Doc/tosubmit2/fig/`1'.pdf", replace
	*! epstopdf "`2'/Doc/tosubmit/fig/`1'.eps"
	*erase "`2'/Doc/tosubmit/fig/`1'.eps"
	project, creates("`2'/Doc/tosubmit2/fig/`1'.pdf")
end	

do "`master'/Code/Est/graph_multirif.do"

graph drop _all
glo qtiles "5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90"
set scheme s1color
graphmultirif, master("`master'") ster(Ster) folders(eoy eoy eoy) qtiles($qtiles) specs(reg_emp_bp reg_emp_bp reg_emp_bp) bites(bite bite bite) times(tq(1999q1) tq(1998q1) tq(1997q1)) axes(1 1 2) twowayopts( xtitle(Percentile) ytitle(Coefficient) ytitle(Coefficient, axis(2)) yscale(range(-0.005 0.005)) xscale(range(5 90)) xlab(10(10)90) ylabel(-0.005(0.0025)0.005, angle(horizontal)) legend(label(1 "Main Estimates 1999q1") label(2 "1998q1") label(6 "1997q1") order(1 2 6) span), (pci -0.005 23 0.005 23, lcolor(black)) (pci -0.005 31 0.005 31, lcolor(cranberry) lpattern(dash)))   

* Had to add text by hand
graph play "`master'/Code/Doc/tosubmit2/measures_formal_edit.grec"

mex measures "`master'"

